<extend name="Public/base"/>

<block name="body">
	<script type="text/javascript" src="__STATIC__/uploadify/jquery.uploadify.min.js"></script>
    <div class="main-title">
        <h2>新增分类</h2>
    </div>
    <ul class="tab-nav nav">
		<li class="current" data-tab="tab1"><a href="javascript:void(0);">基础信息</a></li></li>	
	</ul>
    <form action="{:U()}" method="post" class="form-horizontal">
        <div class="form-item">
            <label class="item-label">分类名称<span class="check-tips"></span></label>
            <div class="controls">
                <input type="text" class="text input-large" name="title" value="{$info['title']}">
            </div>
        </div>
        <div class="form-item">
            <label class="item-label">上级分类<span class="check-tips"></span></label>
            <div class="controls">
                <input type="text" class="text input-large" value="{$pname}" disabled="false">
                <input type="hidden" name="pid" id="pid" value="{$info['pid']}">
                <input type="hidden" name="lev" id="lev" value="{$info['lev']}">
            </div>
        </div>
        <div class="form-item">
            <label class="item-label">排序</label><span class="check-tips">（显示的顺序）</span>
            <div class="controls">
                <input type="text" class="text input-small" name="sort" value="{$info['sort']}">
            </div>
        </div>
        <div class="form-item">
            <label class="item-label">分类图片<span class="check-tips"></span></label>
            <div class="controls">
                <!-- <input type="text" class="text input-large" name="pic" value=""> -->
                <input type="text" class="text input-large" name="pic" id="cover_id_pic" value="{$info['pic']}"/>
                <input type="file" id="upload_picture_pic">
                <div class="upload-img-box">
                    <img src="{$info['pic']}" width="100" height="50">
				</div>
            </div>
            <script type="text/javascript">
				//上传图片
			    /* 初始化上传插件 */
				$("#upload_picture_pic").uploadify({
			        "height"          : 30,
			        "swf"             : "__STATIC__/uploadify/uploadify.swf",
			        "fileObjName"     : "download",
			        "buttonText"      : "上传图片",
			        "uploader"        : "{:U('File/uploadPicture',array('session_id'=>session_id()))}",
			        "width"           : 120,
			        'removeTimeout'	  : 1,
			        'fileTypeExts'	  : '*.jpg; *.png; *.gif;',
			        "onUploadSuccess" : uploadPicture,
			        'onFallback' : function() {
			            alert('未检测到兼容版本的Flash.');
			        }
			    });
				function uploadPicture{$field.name}(file, data){
			    	var data = $.parseJSON(data);
			    	var src = '';
			        if(data.status){
			        	src = data.url || '__ROOT__' + data.path;
			        	$("#cover_id_pic").val(src);
			        	$("#cover_id_pic").parent().find('.upload-img-box').html(
			        		'<div class="upload-pre-item"><img src="' + src + '"/></div>'
			        	);
			        } else {
			        	updateAlert(data.info);
			        	setTimeout(function(){
			                $('#top-alert').find('button').click();
			                $(that).removeClass('disabled').prop('disabled',false);
			            },1500);
			        }
			    }
			</script>
        </div>
        <input type="hidden" name="id" id="id" value="{$info['id']}" />
        <div class="form-item">
            <button class="btn submit-btn ajax-post" id="submit" type="submit" target-form="form-horizontal">确 定</button>
            <button class="btn btn-return" onclick="javascript:history.back(-1);return false;">返 回</button>
        </div>
    </form>
</block>

<block name="script">
    <script type="text/javascript">
        //导航高亮
        highlight_subnav('{:U('GoodsCategory/index')}');
    </script>
</block>